<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<form id="form" method="get">
			账号：<input name="user" id="username"/><br />
			密码：<input name="pwd" id="pass"/><br />
			<input id="check" type="checkbox" />是否要保存账号密码<br />
			<input id="sub" type="submit" />
		</form>
		<script type="text/javascript">
//		localStorage.clear();	
		
		if(parseInt(localStorage.time)<=new Date().getTime()){
			localStorage.clear();
		}
		if(localStorage.length>0){
			username.value=localStorage.name;
			pass.value=localStorage.passd;
		}
		form.onsubmit=()=>{
			if(check.checked){
				localStorage.name=username.value;
				localStorage.passd=pass.value;			
			
			
				var now=new Date();
				//10秒后清除
				var ms=now.getTime()+1000*10;
				localStorage.time=ms;	
			}
		}
			
			console.log(localStorage);
		</script>
	</body>
</html>
